home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
music
/
7
/
modula
/
diamnd.mod
< prev
next >
Wrap
Text File
|
1985-11-19
|
2KB
|
81 lines
IMPLEMENTATION MODULE Diamond ;
(* TDI MOSYS Atari 520 ST : Recursive diamond *)
(* (c) TDI Software Ltd. 1985. *)
FROM GEMVDIbase IMPORT
(* types *) VDIWorkInType, VDIWorkOutType;
FROM VDIOutputs IMPORT
(* procs *) PolyLine ;
FROM VDIControls IMPORT
(* procs *) OpenVirtualWorkstation, CloseVirtualWorkstation ;
FROM AESGraphics IMPORT
(* procs *) GrafHadle;
FROM GemDem IMPORT
(* vars *) WorkX, WorkY ;
VAR currentX, currentY : INTEGER;
Point : ARRAY [0..3] OF INTEGER;
PROCEDURE MoveTo (x, y : INTEGER);
BEGIN
currentX := x;
currentY := y;
END MoveTo;
PROCEDURE LineTo (toX, toY : INTEGER);
BEGIN
Point [0] := currentX;
Point [1] := currentY;
Point [2] := toX;
Point [3] := toY;
MoveTo (toX, toY); (* remember to change currentX, currentY *)
PolyLine (handle, 2, Point);
END LineTo;
PROCEDURE D ( x, y, s : INTEGER );
BEGIN
IF s < m THEN RETURN END;
s := s DIV 2;
D (x+s, y, s);
D (x-s, y, s);
D (x, y-s, s);
D (x, y+s, s);
MoveTo (x, y+s);
LineTo (x+s, y);
LineTo (x, y-s);
LineTo (x-s, y);
LineTo (x, y+s);
END D;
VAR handle : INTEGER;
j : INTEGER;
m : INTEGER;
In : VDIWorkInType;
Out : VDIWorkOutType;
PROCEDURE DoDiamond ;
BEGIN
currentX := WorkX; currentY := WorkY;
FOR j := 0 TO 9 DO In [j] := 1 END;
In [10] := 2;
handle := GrafHandle (j, j, j, j);
OpenVirtualWorkstation (In, handle, Out);
m := 2; (* dropped from 6 to 2 to accomodate lo rez *)
D ( 150, 105, 70 ); (* first dim /2 & -30 halved to accomodate low rez *)
CloseVirtualWorkstation (handle);
END DoDiamond ;
END Diamond.
əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə